import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:kuwo_music/pages/404/index.dart';
import 'package:kuwo_music/pages/home/index.dart';
import 'package:kuwo_music/pages/song_sheet/index.dart';

class Routes {
  static String home = '/';
  static String songSheet = '/songSheet/:id';
  static Handler homeHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return HomePage();
  });

  static Handler songSheetHandler = Handler(
    handlerFunc: (context, parameters) => SongSheet(id: parameters['id'][0]),
  );

  static Handler notFoundHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return NotFoundPage();
  });

  // 路由菜单
  static Map<String, Handler> routeHanderMap = {
    home: homeHandler,
    songSheet: songSheetHandler
  };

  static void configureRoutes(Router router) {
    routeHanderMap.forEach((String name, Handler handler) {
      router.define(name, handler: handler);
    });
    router.notFoundHandler = notFoundHandler;
  }
}
